import request from '@/utils/request'

export function queryUserList(params) {
  return request({
    url: '/plm-sys/api/sysUser/queryPageList',
    method: 'post',
    data: {
      pageNo: params.pageNo,
      pageSize: params.pageSize,
      t: {
        queryStr: params.queryStr,
        status: params.status
      }
    }
  })
}

export function addUser(data) {
  return request({
    url: '/plm-sys/api/sysUser/add',
    method: 'post',
    data
  })
}

export function deleteUser(data) {
  return request({
    url: '/plm-sys/api/sysUser/dels',
    method: 'delete',
    data: data
  })
}

export function enableUser(data) {
  return request({
    url: '/plm-sys/api/sysUser/updateEnable',
    method: 'put',
    withCredentials: true,
    data: data
  })
}

export function disableUser(data) {
  return request({
    url: '/plm-sys/api/sysUser/updateDisableEnable',
    method: 'put',
    data
  })
}

export function copyAddUser(data) {
  return request({
    url: '/plm-sys/api/sysUser/copyadd',
    method: 'post',
    data
  })
}

export function viewUser(id) {
  return request({
    url: '/plm-sys/api/sysUser/view?Id=' + id,
    method: 'get'
  })
}

export function updateUser(data) {
  return request({
    url: '/plm-sys/api/sysUser/update',
    method: 'post',
    data
  })
}

export function getUserGroup(id) {
  return request({
    url: '/plm-sys/api/sysUser/getSysUsergroupWorkspace?userId=' + id,
    method: 'get'
  })
}

export function getUserRoleOrWorkSpace(id) {
  return request({
    url: '/plm-sys/api/sysUser/getSysWorkspaceByUser?userId=' + id,
    method: 'get'
  })
}

export function addWorkSpace(data) {
  return request({
    url: '/plm-sys/api/sysUser/addSysUserWork',
    method: 'post',
    data
  })
}

export function queryWorkSpace(data) {
  return request({
    url: '/plm-sys/api/sysWorkspace/getSysWorkspaces',
    method: 'get'
  })
}

export function deleteSysUserWork(id) {
  return request({
    url: '/plm-sys/api/sysUser/deleteSysUserWork?id=' + id,
    method: 'delete'
  })
}

export function addSysUserWork(data) {
  return request({
    url: '/plm-sys/api/sysUser/addSysUserWork',
    method: 'post',
    data: data
  })
}

export function getSpaceSelect(id) {
  return request({
    url: '/plm-sys/api/selectFilter/user-selectworkspace-s?userId=' + id,
    method: 'get'
  })
}

export function queryAllList() {
  return request({
    url: '/plm-sys/api/sysUser/queryList',
    method: 'GET'
  })
}

export function queryAllGroupList() {
  return request({
    url: '/plm-sys/api/sysUsergroup/queryList',
    method: 'GET'
  })
}
